﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core
{
    public partial class Template
    {
        public override string ToString()
        {
            return this.Name;
        }

        public static IQueryable<Template> GetAll(DAL.DataAccessLayer dal)
        {
            DataAccessDataContext dc = dal.DataContext;
            return from t in dc.Templates
                   select t;
        }

        public static Template Get(DAL.DataAccessLayer dal, String name)
        {
            DataAccessDataContext dc = dal.DataContext;
            var query = from t in dc.Templates
                        where t.Name.Equals(name)
                        select t;
            if (query.Count<Template>() > 0)
                return query.First<Template>();
            return null;
        }
    }
}
